Currently, there are two standard methods of displaying a message to the user in HyperCard without using external code: the message box and the answer dialog. However, the message box is terribly ugly, especially when you have put a lot of work into an elegent graphic interface. The answer dialog isn't always appropriate because it requires a user response, and it disappears before a script can continue to execute. Often what's needed is an elegent way of displaying a message, and the ability to control both invoking and hiding the message from within a script. My solution is ShowMessage.
ShowMessage allows you to control both the display and disposal of a message window from within a script. This is accomplished entirely using HyperCard objects and HyperTalk--no externals are required. Once ShowMessage is set up in a stack, it's very easy to use. The syntax for ShowMessage is:
--display the message
showMessage <string1> [<,string2>]
--hide the message
hideMessage
So for example, if you want to display a message during the course of a lengthy script execution, you would do something like this:
on mouseUp
showMessage "Doing something for a while.","Please wait..."
--do something like...compact the stack...or sort all cards
--when the process is finished
hideMessage
end mouseUp
Go ahead, try it out!
If your script has a repeat loop, you can also 'set the cursor to busy' as a further indication that something is going on (and that the computer hasn't hung up).
Preparing ShowMessage for use is easy. First of all, put the showMessage and hideMessage handlers in your stack script. Secondly, create the message window using three background fields: one for the outside part of the frame and two for the inside part. Name them (in order from back to front) Frame1, Frame2, and TextFrame. Of course, you can name them what you want, but be sure to change the handlers to reflect any other names.
Since you're a HC developer, I'll leave it to you to worry about adjusting the size of the window, and making sure the text looks right when it's displayed. One word of warning though. If you have other buttons and fields in your stack, make sure the ShowMessage window appears on top of them (use 'Bring Forward' and 'Send Farther', or better yet, get my utility SetLayer a.k.a. ChangeObjectLayer). If you're using card buttons and fields in your stack, you may need to construct the ShowMessage window from card fields (thus making it card specific). If need be, you can have several sets of ShowMessage handlers and windows for cards and backgrounds, or for different size windows. For Example:
showMessage1 string1,string2
showMessage2 string1, string2
etc...
Just make the necessary modifications to the handlers. You're the developer! Use your imagination. But please remember, the concept and original handlers for ShowMessage came from me, so credit me if you use them. Thanks.
One final note: if the user aborts your script by typing Command-., you need to dispose of the window in an idle handler:
on idle
if the visible of fld "TextFrame" is true then hideMessage
end idle
Of course, all this would be simpler in an XCMD., but no one has done it, and I'm not a programmer.